package com.lxf.education.controller;

import com.lxf.education.service.StudentListService;
import com.lxf.education.utils.ResultVo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Luoxingfa on 2022/5/2 0002 19:41
 */
@Controller
@RequestMapping("/stu")
public class StudentController {

    @Resource
    StudentListService studentService;
    /**
     *@查询所有数据
     * @return
     */
    @RequestMapping("/findAll")
    @ResponseBody
    public ResultVo getAll(){
        ResultVo resultVo = studentService.getAll();
        return resultVo;
    }

    /**
     * @分页查询
     * @param page 页码
     * @param limit 每行显示条数
     * @return
     */
    @RequestMapping("/findByPage")
    @ResponseBody
    public ResultVo getTeacherList(Integer page, Integer limit) {

        ResultVo resultVo = studentService.getStudentList(page,limit);
        return resultVo;
    }
    

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @RequestMapping("/delAll")
    @ResponseBody
    public ResultVo delAllStus(Integer[] ids){

       return studentService.delAllStu(ids);
    }

    /**
     * @根据id删除
     * @param id
     * @return
     */
    @RequestMapping("/delOne")
    @ResponseBody
    public ResultVo delTeaById(Integer id){
        return  studentService.delStudentById(id);
    }
    /**
     * @根据id更正信息
     * @return
     */
    @RequestMapping("/edit")
    @ResponseBody
    public ResultVo updateStudent(Integer id,String value){

        return studentService.updateStudent(id,value);
    }

    /**
     * @单行查看
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("/lookOne")
    public String lookOne(Integer id, Model model){
        studentService.selById(id);
        return "students/detail_student";
    }
}
